package com.epro.dx.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.epro.dx.R;
import com.weipu.common.facade.model.OrderhistoryModel;

/**
 * 订单状态跟踪适配器
 * @author  qsc255
 * @version  [版本号, 2015-2-3]
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
public class StatusTrackingAdapter extends BaseAdapter
{
    
    private Context mContext;
    
    private List<OrderhistoryModel> orderhistoryModel;
    
    public StatusTrackingAdapter(Context context, List<OrderhistoryModel> orderhistoryModel)
    {
        super();
        this.mContext = context;
        this.orderhistoryModel = orderhistoryModel;
    }
    
    @Override
    public int getCount()
    {
        
        return orderhistoryModel.size() != 0 ? orderhistoryModel.size() : 0;
    }
    
    @Override
    public Object getItem(int position)
    {
        
        return orderhistoryModel.get(position);
    }
    
    @Override
    public long getItemId(int position)
    {
        
        return position;
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        
        ViewHolder viewHolder;
        if (null == convertView)
        {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_statustracking, null);
            viewHolder = new ViewHolder();
            
            viewHolder.status_tracking = (TextView)convertView.findViewById(R.id.order_status);
            viewHolder.track_date = (TextView)convertView.findViewById(R.id.order_date);
            convertView.setTag(viewHolder);
        }
        else
        {
            viewHolder = (ViewHolder)convertView.getTag();
        }
        viewHolder.status_tracking.setText(orderhistoryModel.get(position).getOrderStatusStringFormat());
        viewHolder.track_date.setText(orderhistoryModel.get(position).getChangeOn());
        return convertView;
    }
    
    static class ViewHolder
    {
        TextView status_tracking;
        
        TextView track_date;
    }
}
